package com.xmut.controller;

import com.xmut.pojo.Result;
import com.xmut.pojo.Sv;
import com.xmut.service.SAService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhangbaiyan
 * @date 2024-05-26 01:54
 * @description:
 * @version:
 */
@Slf4j
@RestController
@CrossOrigin("*")
public class SAController {
    @Autowired
    private SAService saService;

    @PostMapping("/service")
    public Result add(@RequestBody Sv service){
        log.info("新增内容{}",service);
        saService.add(service);
        return Result.success();
    }
    @GetMapping("/getAllService")
    public Result getAll()
    {
        List<Sv> svList = saService.getAll();
        return Result.success(svList);
    }
    @DeleteMapping("/delServiceById/{id}")
    public Result delServiceById(@PathVariable Integer id)
    {
        saService.delServiceById(id);
        return Result.success();
    }
}
